﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BUS
{
    public class COption
    {

        public static string EnOrDisApp
        {
            get { return DAO.CConfig.GetValue(DTO.COptionDefault.Name.EnOrDisApp); }
            set
            {
                if(value!=DAO.CConfig.GetValue(DTO.COptionDefault.Name.EnOrDisApp))
                    DAO.CConfig.SetValue(DTO.COptionDefault.Name.EnOrDisApp,value);
            }
        }

        public static string DataPath
        {
            get { return DAO.CConfig.GetValue(DTO.COptionDefault.Name.DataPath); }
            set
            {
                if (value != DAO.CConfig.GetValue(DTO.COptionDefault.Name.DataPath))
                    DAO.CConfig.SetValue(DTO.COptionDefault.Name.DataPath, value);
            }
        }

        public static int DefaultDelay
        {
            get { return Convert.ToInt32(DAO.CConfig.GetValue(DTO.COptionDefault.Name.DefaultDelay)); }
            set
            {
                if (value != Convert.ToInt32(DAO.CConfig.GetValue(DTO.COptionDefault.Name.DefaultDelay)))
                    DAO.CConfig.SetValue(DTO.COptionDefault.Name.DefaultDelay, value.ToString());
            }
        }

        public static string StopRunning
        {
            get { return DAO.CConfig.GetValue(DTO.COptionDefault.Name.StopRunning); }
            set
            {
                if (value != DAO.CConfig.GetValue(DTO.COptionDefault.Name.StopRunning))
                    DAO.CConfig.SetValue(DTO.COptionDefault.Name.StopRunning, value);
            }
        }

        public static void GetPathData()
        {
            OpenFileDialog _Open = new OpenFileDialog();
            _Open.Multiselect = false;
            _Open.Filter = "List keys File (*.xml)|*.xml|All file (*.*)|*.*";
            if (_Open.ShowDialog() == DialogResult.OK)
            {
                DataPath = _Open.FileName;
            }
        }

        public static void SetPathData()
        {
            SaveFileDialog _Save = new SaveFileDialog();
            _Save.FileName = "Data";
            _Save.Filter = "List keys File (*.xml)|*.xml|All file (*.*)|*.*";
            if (_Save.ShowDialog() == DialogResult.OK)
            {
                DataPath = _Save.FileName;
                DAO.CConnectXML.CreateNewTable(_Save.FileName);
            }
        }
    }
}
